package com.connection.second.wallpaper.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.connection.second.common.annotation.Anonymous;
import com.connection.second.wallpaper.domain.page.PaperAlbumRankPage;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.connection.second.common.annotation.Log;
import com.connection.second.common.core.controller.BaseController;
import com.connection.second.common.core.domain.AjaxResult;
import com.connection.second.common.enums.BusinessType;
import com.connection.second.wallpaper.domain.entity.PaperAlbumRank;
import com.connection.second.wallpaper.service.IPaperAlbumRankService;
import com.connection.second.common.utils.poi.ExcelUtil;
import com.connection.second.common.core.page.TableDataInfo;

/**
 * 榜单-专辑排名Controller
 * 
 * @author Ti
 * @date 2024-11-30
 */
@RestController
@RequestMapping("/wallpaper/albumRank")
public class PaperAlbumRankController extends BaseController
{
    @Autowired
    private IPaperAlbumRankService paperAlbumRankService;

    /**
     * 查询榜单-专辑排名列表
     */
    @Anonymous//忽略权限认证
    @GetMapping("/list")
    public TableDataInfo list(PaperAlbumRank paperAlbumRank)
    {
        startPage();
        List<PaperAlbumRankPage> list = paperAlbumRankService.selectPaperAlbumRankList(paperAlbumRank);
        return getDataTable(list);
    }


    /**
     * 获取榜单-专辑排名详细信息
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:albumRank:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paperAlbumRankService.selectPaperAlbumRankById(id));
    }

    /**
     * 新增榜单-专辑排名
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:albumRank:add')")
    @Log(title = "榜单-专辑排名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperAlbumRank paperAlbumRank)
    {
//        System.out.println(paperAlbumRank);
        return toAjax(paperAlbumRankService.insertPaperAlbumRank(paperAlbumRank));
    }

    /**
     * 修改榜单-专辑排名
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:albumRank:edit')")
    @Log(title = "榜单-专辑排名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperAlbumRank paperAlbumRank)
    {
        return toAjax(paperAlbumRankService.updatePaperAlbumRank(paperAlbumRank));
    }

    /**
     * 删除榜单-专辑排名
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:albumRank:remove')")
    @Log(title = "榜单-专辑排名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paperAlbumRankService.deletePaperAlbumRankByIds(ids));
    }
}
